package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.zhanling.BuyRequestResult;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.zhanling.ZhanLingActivityModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * @author ：zfr
 * @date ：2021/4/7 15:27
 */
public class ZhanLingRecharge extends BaseRecharge {
    public ZhanLingRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo) {
        BuyRequestResult buyRequestResult = player.getModule(ZhanLingActivityModule.class).isCanBuyGiftBag(mallInfo.getMallId());
        return !buyRequestResult.isCanBuy();
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        String rewardStr = "";
        BuyRequestResult buyRequestResult = player.getModule(ZhanLingActivityModule.class).isCanBuyGiftBag(mallInfo.getMallId());
        if (buyRequestResult.isCanBuy()) {
            player.getModule(CurrencyModule.class).addCurrency(PropertyHelper.parseStringToProperty(mallInfo.getReward()),
                    eLogMoneyType.Recharge, eLogMoneyType.ReChargeGet);
            logger.info("订单: {}, 购买 战令礼包 商品: {}", orderNo, mallInfo.getMallId());
            player.getModule(ZhanLingActivityModule.class).buyMallSuccess(buyRequestResult);
            rewardStr = mallInfo.getReward();
        }
        return rewardStr;
    }
}
